Skip to main content

All Questions

3votes
2answers
6kviews

Detecting Intersections of a Collection of Singly-Linked Lists

I was recently presented with the following problem... You are given a collection of singly-linked lists (SLLs). Return true if any of them share a common node (or “intersect”), or false otherwise. ...
James Law's user avatar
1vote
1answer
90views

Reverse a sublist of a singly-linked master list in constant space and maximum of one pass (Java)

So I found this funky programming challenge somewhere on Quora. The idea is to take the head of a singly-linked list, and reverse a specific sublist. The requirements are: runs in constant space, ...
coderodde's user avatar
2votes
2answers
93views

remove kth last element from singly-linked list - Follow up

This code is a revised version of implementation which asked for an improvement. Original question is asked here: remove kth last element from singly-linked list credits to: Toby, Andreas, Arkadiusz ...
Erdenebat Ulziisaikhan's user avatar
1vote
2answers
242views

remove kth last element from singly-linked list

I have implemented a code to solve following problem. I would like to improve the code efficiency. Pardon if I just printed out the result. Code has O(N) time and constant space complexity. Given a ...
Erdenebat Ulziisaikhan's user avatar
6votes
2answers
979views

XOR linked list implementation

I am trying to resolve below question in order to prepare for an interview xD An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields, it ...
Erdenebat Ulziisaikhan's user avatar
3votes
1answer
226views

Adding two numbers represented as linked lists

I have some imminent interviews and want to sharpen my game before going into them. I'm running through some practice problems. This LeetCode challenge is to add two numbers represented as linked ...
Scott Skiles's user avatar
1vote
2answers
334views

Leetcode: Merging 2 sorted lists

https://leetcode.com/problems/merge-two-sorted-lists/ Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. ...
Gilad's user avatar
  • 5,293
1vote
2answers
212views

HashMap implementation, is this good enough for interviews?

After understanding HashMaps, I decided to implement my own using 3 classes HashMap, LinkedList, and Node. I knew how to implement LinkedList from before. Can you please give me feedback on this. ...
Rino Leonardino's user avatar
5votes
2answers
503views

Leetcode #146. LRUCache solution in Java (Doubly Linked List + HashMap)

Problem Statement Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be ...
Marko Cain's user avatar
2votes
1answer
309views

Reverse a linked list

I was given 15 minutes to write the code to reverse a singly-linked list. What do you think of the code style here? ...
Gilad's user avatar
  • 5,293
5votes
2answers
1kviews

Remove the first value for a doubly linked list

You need to remove the first element which contains a given value from a doubly linked list. I created two solutions since I find the edge case of removing the first element to be problematic. So I ...
Gilad's user avatar
  • 5,293
2votes
2answers
2kviews

Swap Nodes in Pairs in singly linked list

Description: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only ...
CodeYogi's user avatar
1vote
3answers
806views

Remove nth node from last position in linked list

Description: Given a linked list, remove the nth node from the end of list and return its head. Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the ...
CodeYogi's user avatar
3votes
1answer
211views

Reverse singly linked list

Description: Given a linked list reverse it and return the new head. Code: ...
CodeYogi's user avatar
0votes
3answers
2kviews

Move last node of the linked list to the front

Description: Given a linked list move the last node to the front. For example: 10 20 30 40 -> 40 10 20 30 Code: ...
CodeYogi's user avatar

153050per page
close